<!DOCTYPE html>
<html>
<head>
<title>系统配置</title>
#include("../include/common.html")
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>系统配置</h5>
            </div>
            <form id="inputForm" action="updateList" method="post">
	            <div class="ibox-content">
	                <div class="form-horizontal clearfix">
	                	<div class="form-group">
	                        <div class="col-sm-8">
	                            <a class="btn btn-primary" href="add"><i class="fa fa-plus"></i> 添加</a>
	                        </div>
	                    </div>
	                    <div class="form-group">
                            <label class="col-sm-3 control-label">网站名称：</label>
                            <div class="col-sm-3">
                                <input class="form-control" type="text" name="siteName" value="#(siteName)">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">网站网址：</label>
                            <div class="col-sm-3">
                                <input class="form-control" type="text" name="siteUrl" value="#(siteUrl)">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">网站logo：</label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="logo" value="#(logo)"/>
                            </div>
                            <div class="col-sm-3">
                                <a href="javascript:;" class="btn btn-primary filePicker">选择文件</a>
                                <a href="#(logo)" target="_blank">查看</a>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">网站标题：</label>
                            <div class="col-sm-3">
                                <input class="form-control" type="text" name="title" value="#(title)">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">网站关键词：</label>
                            <div class="col-sm-3">
                                <input class="form-control" type="text" name="keywords" value="#(keywords)">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">网站描述：</label>
                            <div class="col-sm-3">
                                <textarea class="form-control" style="height: 100px;" name="description">#(description)</textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">网站主题：</label>
                            <div class="col-sm-3">
                                <select class="form-control" name="theme">
                                    #for(template : templates)
                                        <option value="#(template)" #if(template==theme) selected #end>#(template)</option> 
                                    #end
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">自定义类型：</label>
                            <div class="col-sm-3">
		                        <textarea class="form-control" style="height: 100px;" name="selfType">#(selfType)</textarea>
		                        <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>(0=未审核,1=正常,不可用于其他) 格式为 数字|名称</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否开启水印：</label>
                            <div class="col-sm-3">
                                <div class="radio">
                                    <label class="m-r"><input name="isWatermarkEnabled" value="true" type="radio" #if(isWatermarkEnabled=="true") checked #end>是</label>
                                    <label class="m-r"><input name="isWatermarkEnabled" value="false" type="radio" #if(isWatermarkEnabled=="false") checked #end>否</label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">水印图片：</label>
                            <div class="col-sm-3">
                                <input class="form-control" type="text" name="watermarkImage" value="#(watermarkImage)">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">水印位置：</label>
                            <div class="col-sm-3">
                                <select class="form-control" name="watermarkPosition">
                                    <option value="no" #if(watermarkPosition=='no') selected #end>无</option>
                                    <option value="topLeft" #if(watermarkPosition=='topLeft') selected #end>左上</option>
                                    <option value="topRight" #if(watermarkPosition=='topRight') selected #end>右上</option>
                                    <option value="center" #if(watermarkPosition=='center') selected #end>居中</option>
                                    <option value="bottomLeft" #if(watermarkPosition=='bottomLeft') selected #end>左下</option>
                                    <option value="bottomRight" #if(watermarkPosition=='bottomRight') selected #end>右下</option>
                                </select>
                            </div>
                        </div>
	                    #for(setting : settings)
		                    <div class="form-group">
		                        <label class="col-sm-3 control-label">#(setting.title)：</label>
	                        	#if(setting.type=="textarea")
			                        <div class="col-sm-3">
	                        			<textarea class="form-control" style="height: 250px;" name="#(setting.name)">#(setting.value)</textarea>
			                        </div>
	                        	#else if(setting.type=="editor")
	                        		<div class="col-sm-8">
	                        			<textarea class="ibox-content no-padding fieldEditor" style="height: 250px;" name="#(setting.name)">#(setting.value)</textarea>
	                        		</div>
	                        	#else if(setting.type=="input")
	                        		<div class="col-sm-3">
	                        			<input class="form-control" type="text" value="#(setting.value)" name="#(setting.name)">
	                        		</div>
	                        	#else if(setting.type=="file")
									<div class="col-sm-3">
										<input type="text" value="#(setting.value)" class="form-control" name="#(setting.name)"/>
									</div>
									<div class="col-sm-1">
                                        <a href="javascript:;" class="btn btn-primary filePicker">选择文件</a>
                                    </div>
	                        	#end
	                        	<div class="col-sm-3">
	                        	    <a href="javascript:;" class="delete" val="#(setting.id)">删除</a>    
	                        	    <a href="edit?id=#(setting.id)">编辑</a>        
	                        	</div>
		                    </div>
	                    #end
	                </div>
	            </div>
	            <div class="modal-footer col-sm-3 col-sm-offset-2">
                    <button type="submit" class="btn btn-w-m btn-primary">确定</button>
                    <button type="button" class="btn btn-w-m btn-default" onclick="history.back(); return false;">取消</button>
                </div>
            </form>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
$().ready(function() {
	
   $.each($(".fieldEditor"),function(index,item){
        $(item).editor();
    });
    
    $.each($(".filePicker"),function(index,item){
        $(item).uploader();
    });

	var $delete = $("#inputForm a.delete");
	
	// 删除
    $delete.click(function() {
        var $this = $(this);
        if(confirm("您确定要删除吗？")){
            $.ajax({
                url: "delete",
                type: "POST",
                data: {id: $this.attr("val")},
                dataType: "json",
                cache: false,
                success: function(message) {
                    if (message.type == "success") {
                        $this.closest(".form-group").remove();
                    }
                }
            });
        }
        return false;
    });

});
</script>


